#!/usr/bin/ruby

def replace_main_banner( content, newbanner )

	# extraer el banner que ya esta en el codigo
	arry = content.split("=end\n")
	if arry.length > 1
		"=begin\n#{newbanner}\n=end\n#{arry[1..-1]}"
	else
		"=begin\n#{newbanner}\n=end\n#{content}"
	end
end

paths_files = ARGV.select{ |x| x =~ /\.rb/}
paths_banner = ARGV.select{ |x| not (x =~ /\.rb/)}

# concatena el contenido de todos los archivos
newbanner = File.open(paths_banner[0]).read

paths_files.each do |path|
	all = File.open(path,"r").read
	result = replace_main_banner( all, newbanner)
	File.open(path,"w").write(result)

	replace_main_banner( path, newbanner )
end
